from selenium.webdriver.common.by import By
from app_ui.base.base_page import BasePage




class DemoPage(BasePage):
    """对象库层"""

    def __init__(self):
        super().__init__()
        self.home_page = (By.XPATH, '//androidx.appcompat.app.ActionBar.c[@content-desc="首页"]')
        self.login = (By.ID, 'com.smile.gifmaker:id/left_text')
        self.mobile_login = (By.XPATH, '//android.widget.TextView[@text="手机号登录"]')
        self.mi_ma = (By.ID, 'com.smile.gifmaker:id/switch_login_way')
        # self.other_login = (By.ID, 'com.smile.gifmaker:id/btn_other_login_ways')
        self.user_agreement = (By.ID, 'com.smile.gifmaker:id/protocol_checkbox')
        self.account = (By.ID, 'com.smile.gifmaker:id/phone_et')
        self.user_password = (By.ID, 'com.smile.gifmaker:id/password_et')
        self.confirm_login = (By.ID, 'com.smile.gifmaker:id/confirm_btn')
        self.search = (By.ID, 'com.smile.gifmaker:id/search_btn')
        self.query_input = (By.ID, 'com.smile.gifmaker:id/editor')
        self.perform_search = (By.XPATH, '//android.widget.TextView[@text="搜索"]')
        self.select_user = (By.XPATH,
                            '//android.widget.HorizontalScrollView[@resource-id="com.smile.gifmaker:id/tabs"]/android.widget.LinearLayout/android.view.View[2]')

        self.i_home = (By.ID, 'com.ss.android.ugc.aweme:id/content_layout')
        self.i_guan_zhu = (By.ID, 'com.ss.android.ugc.aweme:id/skb')
        self.i_zhi_bo = (By.XPATH, 'com.ss.android.ugc.aweme:id/so0')

        self.z_srk = (By.ID, 'com.smile.gifmaker:id/live_comment_text_view')
        self.z_ssrr = (By.ID, 'com.smile.gifmaker:id/editor')
        self.z_fs = (By.ID, 'com.smile.gifmaker:id/finish_button')

    def find_home_page(self):
        self.find_element(self.home_page)

    def find_login(self):
        self.find_element(self.login)

    def find_mobile_login(self):
        self.find_element(self.mobile_login)

    def find_other_login(self):
        self.find_element(self.mi_ma)

    def find_user_agreement(self):
        self.find_element(self.user_agreement)

    def find_account(self):
        self.find_element(self.account)

    def find_password(self):
        self.find_element(self.user_password)

    def find_confirm_login(self):
        self.find_element(self.confirm_login)

    def find_search(self):
        self.find_element(self.search)

    def find_query_input(self):
        self.find_element(self.query_input)

    def find_perform_search(self):
        self.find_element(self.perform_search)

    def find_select_user(self):
        self.find_element(self.select_user)

    def find_i_home(self):
        self.find_element(self.i_home)

    def find_i_guan_zhu(self):
        self.click_button(self.i_guan_zhu)

    def find_i_zhi_bo(self):
        self.find_element(self.i_zhi_bo)

    def find_z_srk(self):
        self.find_element(self.z_srk)

    def find_z_ssrr(self):
        self.find_element(self.z_ssrr)

    def find_z_fs(self):
        self.find_element(self.z_fs)


